﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExportHub2007Content
{
    class Program
    {
        static void DisplayUsage()
        {
            Console.WriteLine("ExportHub2007Content exports key content from an existing 2007 Productivity Hub site collection to the local file system.\r\n");
            Console.WriteLine("Please verify that you have read access to the 2007 Productivity Hub site collection prior to running this tool.\r\n");
            Console.WriteLine();
            Console.WriteLine("Required Parameters:");
            Console.WriteLine("\t-source [hub2007Url] ");
            Console.WriteLine();
            Console.WriteLine("Examples:");
            Console.WriteLine("ExportHub2007Content -source http://farm1/sites/hub");
            Console.WriteLine("ExportHub2007Content -source \"http://sharepoint/hub 2007/\"");
            Console.WriteLine();

        }

        static void Main(string[] args)
        {
            // validate params
            Arguments parseArgs = new Arguments(args);
            bool testMode = false;
            if (!String.IsNullOrEmpty(parseArgs["test"]))
            {
                testMode = true;
            }
            if (String.IsNullOrEmpty(parseArgs["source"]))
            {
                // one or more required params are null/empty
                Console.WriteLine("Error: One ore more required parameters is missing");
                DisplayUsage();
            }
            else
            {
                string logFileName = "ExportHub_" + System.IO.Path.GetRandomFileName().Replace('.', 'a') + ".log";
                System.IO.StreamWriter _logFile = System.IO.File.CreateText(logFileName);

                Exporter m = new Exporter(_logFile, testMode);
                m.SourceUrl = parseArgs["source"];

                m.PerformExport();
                
                // ForumsImportTest fit = new ForumsImportTest(m.SourceUrl);

            }

        }
    }
}
